package cn.hbwe.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalException {

    @ExceptionHandler(CustomException.class)
    public Result<String> customExceptionHandler(CustomException e) {
        log.error("自定义异常信息为：{}",e.getMessage());
        return Result.error(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result<String> systemExceptionHandler(CustomException e) {
        log.error("系统异常异常信息为：{}",e.getMessage());
        return Result.success(e.getMessage());
    }
}
